package com.cxx.initializer;

import org.apache.catalina.LifecycleException;
import org.apache.catalina.connector.Connector;
import org.apache.catalina.startup.Tomcat;

import javax.servlet.ServletException;

public class SpringApplication {

    /**
     * 该方法中会创建Tomcat容器
     */
    public static void run() throws ServletException, LifecycleException {
        // 新建一个tomcat容器
        Tomcat tomcat = new Tomcat();
        Connector connector = new Connector();
        connector.setPort(8082);
        tomcat.addWebapp("/", "D:\\");
        tomcat.getService().addConnector(connector);
        tomcat.start();
        System.out.println("tomcat server initializer");
        tomcat.getServer().await();
    }
}
